package com.unhz.taigu.controller.shiro;

import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.subject.Subject;
import org.apache.shiro.web.filter.authc.FormAuthenticationFilter;
import org.apache.shiro.web.util.WebUtils;

import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

/**
 * 
 * @author cxg
 * @class CustomFormAuthenticationFilter.java
 * @时间 2017年4月5日下午8:53:36
 */
public class CustomFormAuthenticationFilter extends FormAuthenticationFilter {

	//原FormAuthenticationFilter的认证方法
	@Override
	protected boolean onAccessDenied(ServletRequest request,
			ServletResponse response) throws Exception {
		return super.onAccessDenied(request, response);
	}
	/**
	 * 重写loginsuccess成功之后的跳转页面
	 */
	@Override
	protected boolean onLoginSuccess(AuthenticationToken token,
                                     Subject subject, ServletRequest request, ServletResponse response)
			throws Exception {
		//清理期初的地址
		WebUtils.getAndClearSavedRequest(request);
		//重新定义页面
		WebUtils.redirectToSavedRequest(request, response, "/firstIndex.do");
		return false;
		}


		}
